package cn.sgjk.train.business.controller.admin;


import cn.sgjk.train.business.service.DailyTrainStationService;
import cn.sgjk.train.common.context.LoginMemberContext;
import cn.sgjk.train.common.resp.CommonResp;
import cn.sgjk.train.common.resp.PageResp;
import cn.sgjk.train.business.req.DailyTrainQueryReq;
import cn.sgjk.train.business.req.DailyTrainSaveReq;
import cn.sgjk.train.business.resp.DailyTrainQueryResp;
import cn.sgjk.train.business.service.DailyTrainService;
import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/admin/daily-train")
public class DailyTrainAdminController {

    private static final Logger LOG = LoggerFactory.getLogger(DailyTrainAdminController.class);
    @Autowired
    private DailyTrainService dailyTrainService;





    @PostMapping("/save")
    public CommonResp<Object> save(@Valid @RequestBody DailyTrainSaveReq dailyTrainReq) {
        dailyTrainService.save(dailyTrainReq);
        return new CommonResp<>();
    }



    @GetMapping("/query-list")
    public CommonResp<PageResp<DailyTrainQueryResp>> query(@Valid DailyTrainQueryReq dailyTrainQueryReq) {
        PageResp<DailyTrainQueryResp> dailyTrainQueryResps = dailyTrainService.queryList(dailyTrainQueryReq);
        return new CommonResp<>(dailyTrainQueryResps);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResp<Object> delete(@PathVariable Long id) {
        dailyTrainService.delete(id);
        return new CommonResp<>();
    }

    @GetMapping("/gen-daily/{date}")
    public CommonResp<Object> genAll(@PathVariable  @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
        dailyTrainService.genAll(date);
        return new CommonResp<>();
    }

}

